package com.yanqu.road.server.cmd.yrank.union;

import com.yanqu.road.entity.task.args.UnionRiseRankArgs;
import com.yanqu.road.logic.pb.UnionBasePb;
import com.yanqu.road.logic.pb.YRankPb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.rank.YRankProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.yrank.CrossYRankMgr;
import com.yanqu.road.server.protocol.CrossProtocol;

@Cmd(code = CrossProtocol.C2_CROSS_YRANK_UPDATE_UNION_RANK, desc = "")
public class CrossYRankUpdateUnionRankCmd extends CrossUnionCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        YRankProto.UnionYRankUpdateReqMsg reqMsg = YRankProto.UnionYRankUpdateReqMsg.parseFrom(packet.getBytes());

        CrossYRankMgr.unionRankChange(
                reqMsg.getActivityId(),
                reqMsg.getGroupId(),
                reqMsg.getIdKey(),
                reqMsg.getUnionUid(),
                UnionBasePb.parseUnionBaseInfo(reqMsg.getUnionBaseInfo()),
                YRankPb.parsePosMap(reqMsg.getPosListList()),
                UnionRiseRankArgs.NOTIFY_TYPE_NORMAL,
                System.currentTimeMillis(),
                reqMsg.hasParam() ? reqMsg.getParam() : null
        );
    }

    @Override
    public void sendData() {

    }
}
